package it.sd.pwframework.admin.bean;

import java.util.LinkedList;
import java.util.List;

import it.sd.pwframework.business.bean.PwForm;
import it.sd.pwframework.business.service.CommonService;

import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;
import javax.persistence.Transient;

@ManagedBean(name="dbexplorerBean")
@ViewScoped
public class DbExplorerJsfBean extends AbstractJsfBean {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	@ManagedProperty(value="#{commonService}")
	@Transient
    private transient CommonService commonService;


	public CommonService getCommonService() {
		return commonService;
	}

	public void setCommonService(CommonService commonService) {
		this.commonService = commonService;
	}

	private List<PwForm> entities;
	
	@PostConstruct
	public void init() {
		loadEntities();
	}

	private void loadEntities() {
		try {
			entities = new LinkedList<PwForm>();
			entities.addAll(commonService.getForms());
		} catch(Exception e ){
			log.error("error loading entities", e);
		}
	}

	public List<PwForm> getEntities() {
		return entities;
	}

	public void setEntities(List<PwForm> entities) {
		this.entities = entities;
	}

	
	
}
